home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.cs.arizona.edu
/
ftp.cs.arizona.edu.tar
/
ftp.cs.arizona.edu
/
icon
/
newsgrp
/
group03a.txt
/
000075_icon-group-sender_Wed Apr 16 11:58:31 2003.msg
< prev
next >
Wrap
Internet Message Format
|
2003-12-22
|
1KB
Return-Path: <icon-group-sender>
Received: (from root@localhost)
by baskerville.CS.Arizona.EDU (8.11.1/8.11.1) id h3GIvO608433
for icon-group-addresses; Wed, 16 Apr 2003 11:57:24 -0700 (MST)
Message-Id: <200304161857.h3GIvO608433@baskerville.CS.Arizona.EDU>
Date: Wed, 16 Apr 2003 11:09:39 +1200 (NZST)
From: "Richard A. O'Keefe" <ok@cs.otago.ac.nz>
To: icon-group@cs.arizona.edu, rlb@hoekstra-uitgeverij.nl
Subject: Re: Simplifying Integer Arithmetic
X-scanner: scanned by Inflex 1.0.12.4 - (http://pldaniels.com/inflex/)
Errors-To: icon-group-errors@cs.arizona.edu
Status: RO
Richard Bos <rlb@hoekstra-uitgeverij.nl>
explained about / and % in C89 and C99.
However, it is worth pointing out that the C89 standarisers
were aware of the issue. They chose to deal with it not by
requiring incompatible changes to existing compilers (like
they did with signed@unsigned combinations) but by adding a
pair of library functions:
div(int n, int d) => a div_t containing quotient and remainder
ldiv(long n, long d) => an ldiv_t containing quotient and remainder
where the quotient is sign(n/d)*floor(abs(n/d)).
So if you want a fully specified truncate-towards-zero quotient
and/or remainder in C89, you use div() or ldiv() depending on the
size of the operands.